package com.wb.cloud_provider.controller;

import com.wb.cloud_provider.bean.Movie;
import com.wb.cloud_provider.bean.Type;
import com.wb.cloud_provider.dao.TypeDao;
import com.wb.cloud_provider.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resources;
import java.util.List;

@CrossOrigin
@RequestMapping("movie")
@RestController
public class MovieController {

    @Autowired
    private TypeDao typeDao;
    @Autowired
    private TypeService typeService;

    /**
     * 电影分类
     * @return
     */
    @RequestMapping("variety")
    public List<Type> variety(){
        List<Type> types = typeDao.SelectType();
        return types;
    }

    /**
     * 电影列表
     * @param id
     * @return
     */
    @RequestMapping("movie")
    public List<Movie> movie(String id){
        if(id==null){
            id="1";
        }
        Integer i =(Integer)Integer.parseInt(id);
//        List<Movie> movies = typeDao.SelectMovie(i);
        List<Movie> movies = typeService.SelectMovie(i);
        return movies;
    }
}
